package cn.itsource.service.impl;

import cn.itsource.domain.Teacher;
import cn.itsource.mapper.TeacherMapper;
import cn.itsource.service.ITeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * TeacherServiceImpl类实现了ITeacherService接口，用于处理教师信息的业务逻辑
 */
@Service
public class TeacherServiceImpl implements ITeacherService {
    // 使用@Autowired注解自动装配TeacherMapper对象
    @Autowired
    private TeacherMapper teacherMapper;

    /**
     * 保存教师信息
     * @param teacher 教师对象
     */
    @Override
    public void save(Teacher teacher) {
        // 调用TeacherMapper的save方法保存教师信息
        teacherMapper.save(teacher);
    }

    /**
     * 更新教师信息
     * @param teacher 教师对象
     */
    @Override
    public void update(Teacher teacher) {
        // 调用TeacherMapper的update方法更新教师信息
        teacherMapper.update(teacher);
    }

    /**
     * 删除指定id的教师信息
     * @param id 教师id
     */
    @Override
    public void dlt(Long id) {
        // 调用TeacherMapper的dlt方法删除指定id的教师信息
        teacherMapper.dlt(id);
    }

    /**
     * 获取指定id的教师信息
     * @param id 教师id
     * @return 对应id的教师信息
     */
    @Override
    public Teacher get(Long id) {
        // 调用TeacherMapper的get方法获取指定id的教师信息
        return teacherMapper.get(id);
    }

    /**
     * 获取所有教师信息
     * @return 所有教师信息的列表
     */
    @Override
    public List<Teacher> getAll() {
        // 调用TeacherMapper的getAll方法获取所有教师信息的列表
        return teacherMapper.getAll();
    }

    @Override
    public void batchInsert(List<Teacher> teachers) {
        if(teachers.size() == 0){
            return;
        }else {
            //批量插入老师数据
            teacherMapper.batchInsert(teachers);
        }

    }
}
